package com.qfedu.zf.index.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qfedu.zf.common.vo.R;
import com.qfedu.zf.index.entity.Store;
import com.qfedu.zf.index.mapper.StoreMapper;
import com.qfedu.zf.index.service.StoreService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.awt.geom.QuadCurve2D;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wgz
 * @since 2024-06-20
 */
@Service
public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements StoreService {

    @Autowired
    StoreMapper storeMapper;

    @Override
    public R listAll(Map<String, Object> map) {
        QueryWrapper<Store> wrapper = new QueryWrapper<>();
        if (map.get("name") != null && map.get("name") != ""){
            wrapper.like("name",map.get("name"))
                    .or()
                    .like("address",map.get("name"));
            try {
                wrapper.or().like("phone",map.get("name"));
            }catch (Exception ignored) {}
        }
        List<Store> stores = storeMapper.selectList(wrapper);
        if (stores == null){
            return R.fail("未查到店铺");
        }
        return R.ok(stores);
    }
}
